package cc.verywell.pureblock.msg.nfs.linkmap;


/**
* 
* Copyright © 2019 TanYaqiu. All rights reserved.
* @author TanYaqiu 
* @address flat 601
* @date 2019年6月16日 下午3:24:34
*/
public class EasyIteratorNoRemove implements EasyIterator{

	final EasyIterator it;
	public EasyIteratorNoRemove(EasyIterator it) {
		this.it = it;
		next();
	}

	private LinkCell current;
	@Override
	public boolean hasNext() {
		return current!=null;
	}

	@Override
	public LinkCell next() {
		LinkCell cr = current;
		LinkCell last = cr; 
		current = null;
		while(it.hasNext()) {
			LinkCell nxt = it.next();
			if(!nxt.equalsWithoutSeq(last, 0)) {
				if(nxt.isRemove()) {
					last = nxt;
				}else {
					current = nxt;
					break;
				}
			}
		}
		return cr;
	}

	@Override
	public LinkCell current() {
		return current;
	}
	
}
